package com.xcc.cloud.stream.provider;

import cn.hutool.core.util.IdUtil;
import com.xcc.cloud.stream.source.MqMessageSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;

//@EnableBinding(Source.class)
@EnableBinding(MqMessageSource.class) //定义消息的推送管道
public class MessageProviderImpl implements IMessageProvider {

    @Resource(name = MqMessageSource.OUT_PUT)
    private MessageChannel output;
    @Resource(name = MqMessageSource.OUT_PUT1)
    private MessageChannel output1;
    @Resource(name = MqMessageSource.OUT_PUT2)
    private MessageChannel output2;

    @Override
    public String send() {
        String serial = IdUtil.simpleUUID();
        boolean send = output.send(MessageBuilder.withPayload(serial).build());
        System.out.println("output******************serial: "+serial+"\t发送情况"+send);
        return serial;
    }

    @Override
    public String send1() {
        String serial = IdUtil.simpleUUID();
        boolean send = output1.send(MessageBuilder.withPayload(serial).build());
        System.out.println("output1******************serial: "+serial+"\t发送情况"+send);
        return serial;
    }

    @Override
    public String send2() {
        String serial = IdUtil.simpleUUID();
        boolean send = output2.send(MessageBuilder.withPayload(serial).build());
        System.out.println("output2******************serial: "+serial+"\t发送情况"+send);
        return serial;
    }

}
